<template>
	<view class="foot">
		<view class="tabs">
			<view class="bar"
			 v-for="(item, index) in navList"
			 :key='index'
			 @click="tabBarHandle(item, index)"
			>
				<image class='icon' :src="item.active==1?item.selectedIcon:item.icon"></image>
				<view class="number" v-if="item == 'cart'"></view>
				<view class="test" :class="{'active': item.active==1}">{{item.active}}{{item.name}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {mapState, mapMutations} from 'vuex'
	import TabBarItem from './TabBarItem'
	export default {
		data() {
			return {
				title: 'Hello'
			}
			
		},
		components: {
			TabBarItem
		},
		computed: {
			...mapState(['btmActive', 'navList'])
		},
		methods: {
			...mapMutations(['btmNavNavigator']),
			tabBarHandle(item, index) {
				console.log('12312', this.navList)
				if (item.src == 'home') {
					uni.navigateTo({
						url:'../index/index'
					})
				} else if (item.src == 'class') {
					uni.navigateTo({
						url:'../class/index'
					})
				} else if (item.src == 'cart') {
					uni.navigateTo({
						url:'../cart/index'
					})
				} else if (item.src == 'user') {
					uni.navigateTo({
						url:'../account/index'
					})
				}
				this.btmNavNavigator(index)
			}
		}
	}
</script>

<style lang="less">
	.foot{
		height: 100rpx;
		background: #fff;
		box-shadow: 0 0 5rpx 0 #fbfbfb;
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		z-index: 50;
		.tabs{
			height: 80rpx;
			padding-top: 10rpx;
			color: #666;
			display: flex;
			justify-content: space-around;
			align-items: center;
		}
		.bar{
			display: flex;
			flex-direction: column;
			align-items: center;
			.icon{
				width: 54rpx;
				height: 54rpx;
			}
			.active {
				color: #7ec5cf;
			}
			.test{
				font-size: 20rpx;
			}
			.number{
				width: 20rpx;
				border-radius: 50%;
			}
		}
	}
</style>
